package com.itheima.springboottest;

import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class logAOP {

    @Pointcut("execution(* com.itheima.springboottest.HelloServiceImpl.*(..))")
    public void kk(){}
    @Around("kk()")
    public Object around(ProceedingJoinPoint prd) throws Throwable {
        long start = System.nanoTime();
        Object proceed = prd.proceed();
        long end = System.nanoTime();
        log.info("耗时：{}",end-start);
        return proceed;
    }
    @Before("kk()")
    public void bofore(){
        log.info("开始执行");
    }

    @After("kk()")
    public void after(){
        log.info("执行完成");
    }
}
